package com.meetingshow.commu.service;

import java.util.ArrayList;
import java.util.List;

import com.meetingshow.common.base.dao.model.QueryStruct;
import com.meetingshow.common.base.service.BaseServiceImp;
import com.meetingshow.common.base.service.model.QueryResults;
import com.meetingshow.commu.dao.QuestionDAO;
import com.meetingshow.commu.dao.model.QuestionPO;
import com.meetingshow.commu.service.model.QuestionQueryParas;
import com.meetingshow.commu.service.util.QuestionQueryParasBuilder;
import com.meetingshow.commu.service.util.QuestionServiceParas;

public class QuestionServiceImp extends BaseServiceImp implements
        IQuestionService {

    private QuestionDAO questionDAO;

    /**
     * @return the questionDAO
     */
    public QuestionDAO getQuestionDAO() {
        return questionDAO;
    }

    /**
     * @param questionDAO
     *            the questionDAO to set
     */
    public void setQuestionDAO(QuestionDAO questionDAO) {
        this.questionDAO = questionDAO;
    }

    @Override
    public Integer saveQuestion(QuestionPO questionPO) throws Exception {
        return getQuestionDAO().saveQuestion(questionPO);
    }

    @Override
    public void updateQuestion(QuestionPO questionPO) throws Exception {
        getQuestionDAO().updateQuestion(questionPO);
    }

    @Override
    public void removeQuestion(QuestionPO questionPO) throws Exception {
        getQuestionDAO().removeQuestion(questionPO);
    }

    @Override
    public QuestionPO loadQuestionById(Integer questionId) throws Exception {
        return getQuestionDAO().loadQuestionById(questionId);
    }
    
    @Override
    public QueryResults<QuestionPO> queryQuestion(
            QuestionQueryParas questionQueryParas) throws Exception {
        QueryStruct queryStruct = new QueryStruct();
        List<String> tableList = new ArrayList<String>();
        List<String> returnObjectList = new ArrayList<String>();

        tableList.add(QuestionServiceParas.QUESTION_PO);
        returnObjectList.add(QuestionServiceParas.QUESTION_PO);

        queryStruct.setTableList(tableList);
        queryStruct.setReturnObjectList(returnObjectList);

        queryStruct = QuestionQueryParasBuilder.questionQueryBuilder(
                queryStruct, questionQueryParas);
        QueryResults<QuestionPO> queryResults = getQuestionDAO().queryQuestion(
                queryStruct);
        return queryResults;
    }

}
